package com.mdd.common.mapper.order;

import com.mdd.common.core.basics.IBaseMapper;
import com.mdd.common.entity.order.OrderRefund;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.Map;

/**
 * 订单退款Mapper
 * @author panweiliang
 */
@Mapper
public interface OrderRefundMapper extends IBaseMapper<OrderRefund> {


    @Select({"SELECT COUNT(id) AS refundCount FROM ls_order_refund WHERE refund_status = #{refundStatus} "})
    Integer countByRefundStatus(Integer refundStatus);

    @Select({"SELECT IFNULL(SUM(refund_amount), 0) AS totalMoney FROM ls_order_refund WHERE refund_status = #{refundStatus} "})
    BigDecimal getTotalMoneyByRefundStatus(Integer refundStatus);

    @Select({"SELECT COUNT(id) AS refundCount FROM ls_order_refund "})
    Integer countAll();

    @Select({"SELECT IFNULL(SUM(refund_amount), 0) AS totalMoney FROM ls_order_refund "})
    BigDecimal getTotalMoney();

    @Select({"SELECT IFNULL(SUM(refund_amount), 0) AS totalMoney FROM ls_order_refund WHERE refund_status = 1"})
    BigDecimal getRefundedTotalAmount();

}
